<script>
import {data} from "autoprefixer";

export default {
  data() {
    var validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入密码'));
      } else {
        if (this.user.checkPass !== '') {
          this.$refs.ruleForm.validateField('checkPass');
        }
        callback();
      }
    };
    var validatePass2 = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'));
      } else if (value !== this.user.userPass) {
        callback(new Error('两次输入密码不一致!'));
      } else {
        callback();
      }
    };
    return {
      labelPosition: 'right',
      user: {
        care:'',
        userName:'',
        userPass: '',
        checkPass: '',
        num:'',
        userMail:''
      },
        msg:'',

      rules: {
        pass: [
          { validator: validatePass, trigger: 'blur' }
        ],
        checkPass: [
          { validator: validatePass2, trigger: 'blur' }
        ],
      }
    };
  },
  methods: {
    sendnum(){
    },

    submitForm() {
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
}


</script>

<template>
  <div class="zc" >
    <el-form style="border-radius: 2px" :label-position="labelPosition" :model="user" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="账号" prop="userName">
        <el-input v-model="user.userName"></el-input>
      </el-form-item>
      <el-form-item label="身份证号" prop="userName">
        <el-input v-model="user.care"></el-input>
      </el-form-item>
      <el-form-item
        prop="userMail"
        label="邮箱"
        :rules="[
      { required: true, message: '请输入邮箱地址', trigger: 'blur' },
      { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
    ]"
      >
        <el-input v-model="user.userMail"></el-input>
        <el-button @click="sendnum">发送验证码</el-button>
      </el-form-item>
      <el-form-item label="验证码" prop="num" >
        <el-input v-model="user.num"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="userPass">
        <el-input type="password" v-model="user.userPass" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="确认密码" prop="checkPass">
        <el-input type="password" v-model="user.checkPass" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm()">确认注册</el-button>
        <el-button @click="resetForm('ruleForm')">重置信息</el-button>
      </el-form-item>
    </el-form>
  </div>

</template>

<style>
.zc{
  width: 500px;
}

</style>
